package cn.wgx.modules.sys.util;

import cn.wgx.commons.util.SpringContextHolder;
import cn.wgx.modules.sys.entity.SysRes;
import cn.wgx.modules.sys.services.SysResService;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

public class ResUtil {

    private static SysResService saveResource;

    static{
        saveResource = SpringContextHolder.getBean("sysResService");
    }

    public static SysRes getByMD5(String md5){
        return saveResource.getOneByMD5(md5);
    }

    public static String getMD5ByPath(String path){
        return saveResource.getMD5ByPath(path);
    }
    public static void save(MultipartFile attach, String path, String comeFrom, String md5, HttpServletRequest request){
        saveResource.saveResource(attach,  path,  comeFrom,  md5,  request);
    }

    public static void save(String fileName, Long size, String path, String comeFrom, String md5,HttpServletRequest request){
        saveResource.saveResource(fileName,  size, path,  comeFrom,  md5,  request);
    }


    public static int updateUserByUrl(String url){
        return saveResource.updateUserByUrl(url);
    }

}
